package com.eascs.o2o.recruit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.eascs.o2o.recruit.entity.FeedbackEntity;
import com.eascs.o2o.recruit.service.FeedbackService;

@Controller
public class FeedbackController {

	@Autowired
	@Qualifier("feedbackServiceImpl")
	private FeedbackService eedbackService;
	
	@RequestMapping("/feedback/index")
	public String feedback() {
		return "/recruit/feedback";
	}

	@RequestMapping(value = "/submit/feedback", method = RequestMethod.POST)
	public ModelAndView submitFeedback(FeedbackEntity feedback) {
		ModelAndView mv = new ModelAndView();
		int result = eedbackService.saveFeedback(feedback);
		if (result > 0) {
			mv.addObject("result", true);
			mv.setViewName("/recruit/feedbackSuccess");
			return mv;
		}
		mv.addObject("errorMsg","提交失败，请联系管理员!");
		mv.setViewName("/recruit/feedback");
		return mv;
	}
}
